extends Node
class_name WizardSkill

@export var wizard: Wizard
@onready var body: Node2D = %body
@onready var state_chart: StateChart = %StateChart
@export var fire_ball_scene: PackedScene
@onready var attack_vfx: AnimatedSprite2D = %attack_vfx

var target_player:Player:
	get:
		return Utils.player
		
func rage():
	#wizard.wizard_stats.set_bool("can_attack", false)
	#ice()
	#await get_tree().create_timer(wizard.wizard_stats.get_float("attack_cooldown")).timeout
	#wizard.wizard_stats.set_bool("can_attack", true)
	pass
# 冰霜攻击
func ice() -> void:
	attack_vfx.global_position = Utils.player.global_position
	wizard.animation_player.play("attack1")

# 火球攻击	
func fire() -> void:
	if fire_ball_scene and target_player:
		var fire_ball = fire_ball_scene.instantiate()
		fire_ball.damage = wizard.wizard_stats.get_float("damage")
		fire_ball.speed = 500.0
		fire_ball.lifetime = 10.0
		fire_ball.explosion_radius = 150.0
		# 初始化火球
		fire_ball.init(wizard.attack_vfx.global_position, (Utils.player.global_position - attack_vfx.global_position), true)
		wizard.get_parent().add_child(fire_ball)
		
